<div class="portlet light bordered">
	<div class="portlet-body form resultsTable">
		     
		      <div class="portlet box green" style="border-top: 1px solid #5cd1db">
				   <div class="portlet-body form">
						<div class="form-body">
					   <div class="row">
						   <label class="control-label col-md-2" style="text-align: center;margin-top: 8px;">货品名称：</label>
						   <div class="col-md-2">
							   <input type="text" class="form-control" id ="seeId"  name= "name" value="$!name"/>
						   </div>
						   <input type="hidden" name="labels" id="labelsId" value="$!labels">
						   <label class="control-label col-md-2" style="text-align: center;margin-top: 8px;">商品分类：</label>
						   <div class="col-md-2">
							   <select class="js-data-getAttr-ajax2 form-control" name="categorys">
									</select>
						   </div>
						   <div class="col-md-3" style="text-align: center;">
								   <a href="javascript:;" class="btn green btn-sm d_checksee"><i class="fa fa-search"></i>查询</a>
								   <a href="javascript:;" class="btn green btn-sm d_reset"><i class="fa fa-eraser"></i> 清除 </a>
						   </div>
							</div>
				   </div>
					</div>
				  <script>
                      function formatAttr(repo) {
                          if (repo.loading) {
                              return repo.text;
                          }
                          var markup = "<div class='select2-result-repository clearfix'>"
                              + "<div class='select2-result-repository__meta' style='margin-left: 4px'>"
                              + "<div class='select2-result-repository__title'>" + repo.name+"</div>"
                              + "<div class='select2-result-repository__description'>"+ repo.id + "</div>"
                              +"</div>"
                              +"</div>";
                          return markup;
                      }

                      function formatRepoSelection(repo) {
                          return   repo.id;
                      }
$(' .js-data-getAttr-ajax2').select2({
    ajax : {
        url : "/productLabel/getCategory",
        dataType: 'json',
        delay : 250,
        async : false,
        data : function(params) {
            console.log(params);
            var term= params.term ;
            var map = {};
            map["str"] = term;
            return {

                str:map["str"] ,
                pageNo : params.page||1
            };
        },
        processResults: function (data, params) {
            params.page = params.page || 1;

            return {
                results: data.result,
                pagination: {
                    more: (params.page * 10) < data.totalCount
                }
            };
        },
        cache : true
    },
    width : "off",
    escapeMarkup : function(markup) {
        return markup;
    },
    placeholder:'请选择',
    minimumInputLength : 1,
    language: "zh-CN",
    templateResult : formatAttr,
    templateSelection : formatRepoSelection
});
				  </script>
             </div>
             
			<div class="table-container table-scrollable">
				<table class="table table-bordered table-hover icheck-table">
					<thead>
						<tr>
							<th>序号</th>
							<th>货品名称</th>
							<th>分类</th>
							<th>品牌</th>
							<th>总库存</th>
							<th>总销量</th>
							<th>排序</th>
						</tr>
					</thead>
					<tbody>
						#foreach($!item in $!pagePro.result)
						    #set($index = ($velocityCount))
					        #set($inventory=$!inventoryMap.get($!item))
					    <tr>
					        
							<td>$!index </td>
							<td>$!item.name</td>
							<td>$!item.category.name</td>
							<td>$!item.brandName</td>
							<td>$!inventory.inventory</td>
							<td>$!item.salesNum</td>
							<td><input class="form-control col-md-6 input-small showSort" id="$!item.id"  type="text" value="$!item.showSort" style="width: 100px;background-color: #EEF1F5"> </td>
					    </tr>
				    #end
					</tbody>
				</table>
			</div>
			<div class="form-actions right">
				<a href="javascript:;" data-dismiss="modal" class="btn btn-outline grey-salsa">返回</a>
			</div>
	
	</div>
	   #set($page=$!pagePro)
			#set($pageUrl="/productLabel/checkSee?labels=$!labels&name=$!name&pageNo=")
			#parse("_page.htm")
</div>
<script type="text/javascript" src="/assets/scripts/views-icheck.js"></script>
<script src="/assets/scripts/views.js" type="text/javascript"></script>



<script type="text/javascript">
<!--

//-->
$(".d_checksee").click(function(){
	var pageContentBody = $(".modal-content");
	var seeid = $("#seeId").val();
	var labelsId = $("#labelsId").val();
	var cateId = $(".js-data-getAttr-ajax2").val();
		$.get("productLabel/checkSee",{"name":seeid,"labels":labelsId,"categoryId":cateId},function(result){
		    console.log(result);
			pageContentBody.html(result);
		});
})

$(".d_reset").click(function(){
	  $("#seeId").val("");
})

$(".showSort").focusout(function(){
	var showSort=$(this).val()*1;
	var id=$(this).attr("id");
	//productLabel/updateSort
		$.get("productLabel/updateShow",{"id":id,"showSort":showSort},function(res){
			toastr.success('操作成功!');
			
		})
	
})   
//blur  focusout


//分页
 $(".lables").click(function(){

	var seeid = $("#seeId").val();
	var labelsId = $("#labelsId").val();
	var pageContentBody = $(".modal-content");
	var url=$(this).attr("href");
	
	  $.ajax({
          type: "get",
          url: url,
          dataType: "html",
          success: function (res) {
             pageContentBody.html(res);   
          },
          error: function (xhr, ajaxOptions, thrownError) {
              pageContentBody.html('<h4>服务器异常!</h4>');
              App.stopPageLoading();
          }
      });

	 return false;  
}); 
</script>

